package com.stylefeng.guns.core.util.appSecure;

import javax.servlet.http.HttpServletRequest;

/**
 * 移动端认证工具类
 * @author yywpc
 *
 */
public class AppSecure {
	/**AppID */
	private String a;
	/**业务数据 */
	private byte[] data;
	/** 计算jsonString MD5 */
	private String dataMD5;
	/**rsa加密密钥 */
	private String k;
	/**加密后内容的md5值 */
	private String m;
	/** 拼接参数  token + a + dataMD5 + s */
	private String parameterStr;
	/** 签名值*/
	private String s;
	/**时间戳 */
	private String t;
	/** 协议版本号 */
	private String v;
	
	public AppSecure(HttpServletRequest request, byte[] jsonString) {
		super();
		this.data = jsonString;
		this.m = request.getHeader("m");
		this.k = request.getHeader("k");
		this.t = request.getHeader("t");
		this.s = request.getHeader("s");
		this.v = request.getHeader("v");
		this.a = request.getHeader("a");
		
		this.dataMD5 = HashUtil.md5(data).toLowerCase();
		//  sprintf (buf, "%s%s%ul%s", sd_md5, token, (long)timeStamp, app_id);
		this.parameterStr = HashUtil.sha1((dataMD5+RSAUtil.token+t+a).getBytes());
	}

	public String getA() {
		return a;
	}

	public void setA(String a) {
		this.a = a;
	}

	public byte[] getData() {
		return data;
	}

	public void setData(byte[] data) {
		this.data = data;
	}

	public String getDataMD5() {
		return dataMD5;
	}

	public void setDataMD5(String dataMD5) {
		this.dataMD5 = dataMD5;
	}

	public String getK() {
		return k;
	}

	public void setK(String k) {
		this.k = k;
	}

	public String getM() {
		return m;
	}

	public void setM(String m) {
		this.m = m;
	}

	public String getParameterStr() {
		return parameterStr;
	}

	public void setParameterStr(String parameterStr) {
		this.parameterStr = parameterStr;
	}

	public String getS() {
		return s;
	}

	public void setS(String s) {
		this.s = s;
	}

	public String getT() {
		return t;
	}

	public void setT(String t) {
		this.t = t;
	}

	public String getV() {
		return v;
	}

	public void setV(String v) {
		this.v = v;
	}
	//==
}
